/**
 * 
 */
package com.feonix.common.util.mvc;

import org.springframework.web.multipart.MultipartFile;

/**
 * @CopyRight (c)1993-2017
 * @Project m-complat-common
 * @Comments 封装的spring的文件上传对象
 * @NameSpace com.feonix.common.util.mvc
 * @Author Feonixzw
 * @CreateDate 2017年11月27日
 */
public class MultipartFileInfo {

	private String fileFullName;
	private String fileName;
	private String fileType;
	private long size;

	public static MultipartFileInfo getInstance(MultipartFile multipartFile) {
		return new MultipartFileInfo(multipartFile);
	}

	private MultipartFileInfo(MultipartFile multipartFile) {
		if ((multipartFile == null) || (multipartFile.isEmpty())) {
			return;
		}

		this.size = multipartFile.getSize();
		this.fileFullName = multipartFile.getOriginalFilename();
		this.fileName = multipartFile.getOriginalFilename();
		if (this.fileName.contains(".")) {
			int index = this.fileName.lastIndexOf(".");
			this.fileType = this.fileName.substring(index + 1).toLowerCase();
			this.fileName = this.fileName.substring(0, index);
		}
	}

	public String getFileFullName() {
		return this.fileFullName;
	}

	public String getFileName() {
		return this.fileName;
	}

	public String getFileType() {
		return this.fileType;
	}

	public long getSize() {
		return this.size;
	}

}
